//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS PersonalizeEvents service.
///
/// Amazon Personalize can consume real-time user event data, such as stream or click data, and use it for model training either alone or combined with historical data. For more information see  Recording item interaction events.
public struct PersonalizeEvents: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the PersonalizeEvents client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "PersonalizeEvents",
            serviceIdentifier: "personalize-events",
            signingName: "personalize",
            serviceProtocol: .restjson,
            apiVersion: "2018-03-22",
            endpoint: endpoint,
            errorType: PersonalizeEventsErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Records action interaction event data. An action interaction event is an interaction between a user and an action.  For example, a user taking an action, such a enrolling in a membership program or downloading your app.  For more information about recording action interactions, see Recording action interaction events. For more information about actions in an Actions dataset, see Actions dataset.
    @Sendable
    @inlinable
    public func putActionInteractions(_ input: PutActionInteractionsRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "PutActionInteractions", 
            path: "/action-interactions", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Records action interaction event data. An action interaction event is an interaction between a user and an action.  For example, a user taking an action, such a enrolling in a membership program or downloading your app.  For more information about recording action interactions, see Recording action interaction events. For more information about actions in an Actions dataset, see Actions dataset.
    ///
    /// Parameters:
    ///   - actionInteractions: A list of action interaction events from the session.
    ///   - trackingId: The ID of your action interaction event tracker. When you create an Action interactions dataset, Amazon Personalize creates an action interaction event tracker for you. For more information, see Action interaction event tracker ID.
    ///   - logger: Logger use during operation
    @inlinable
    public func putActionInteractions(
        actionInteractions: [ActionInteraction],
        trackingId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = PutActionInteractionsRequest(
            actionInteractions: actionInteractions, 
            trackingId: trackingId
        )
        return try await self.putActionInteractions(input, logger: logger)
    }

    /// Adds one or more actions to an Actions dataset. For more information see  Importing actions individually.
    @Sendable
    @inlinable
    public func putActions(_ input: PutActionsRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "PutActions", 
            path: "/actions", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds one or more actions to an Actions dataset. For more information see  Importing actions individually.
    ///
    /// Parameters:
    ///   - actions: A list of action data.
    ///   - datasetArn: The Amazon Resource Name (ARN) of the Actions dataset you are adding the action or actions to.
    ///   - logger: Logger use during operation
    @inlinable
    public func putActions(
        actions: [Action],
        datasetArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = PutActionsRequest(
            actions: actions, 
            datasetArn: datasetArn
        )
        return try await self.putActions(input, logger: logger)
    }

    /// Records item interaction event data. For more information see  Recording item interaction events.
    @Sendable
    @inlinable
    public func putEvents(_ input: PutEventsRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "PutEvents", 
            path: "/events", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Records item interaction event data. For more information see  Recording item interaction events.
    ///
    /// Parameters:
    ///   - eventList: A list of event data from the session.
    ///   - sessionId: The session ID associated with the user's visit. Your application generates the sessionId when a user first visits your website or uses your application.  Amazon Personalize uses the sessionId to associate events with the user before they log in. For more information, see  Recording item interaction events.
    ///   - trackingId: The tracking ID for the event. The ID is generated by a call to the CreateEventTracker API.
    ///   - userId: The user associated with the event.
    ///   - logger: Logger use during operation
    @inlinable
    public func putEvents(
        eventList: [Event],
        sessionId: String,
        trackingId: String,
        userId: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = PutEventsRequest(
            eventList: eventList, 
            sessionId: sessionId, 
            trackingId: trackingId, 
            userId: userId
        )
        return try await self.putEvents(input, logger: logger)
    }

    /// Adds one or more items to an Items dataset. For more information see  Importing items individually.
    @Sendable
    @inlinable
    public func putItems(_ input: PutItemsRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "PutItems", 
            path: "/items", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds one or more items to an Items dataset. For more information see  Importing items individually.
    ///
    /// Parameters:
    ///   - datasetArn: The Amazon Resource Name (ARN) of the Items dataset you are adding the item or items to.
    ///   - items: A list of item data.
    ///   - logger: Logger use during operation
    @inlinable
    public func putItems(
        datasetArn: String,
        items: [Item],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = PutItemsRequest(
            datasetArn: datasetArn, 
            items: items
        )
        return try await self.putItems(input, logger: logger)
    }

    /// Adds one or more users to a Users dataset. For more information see  Importing users individually.
    @Sendable
    @inlinable
    public func putUsers(_ input: PutUsersRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "PutUsers", 
            path: "/users", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds one or more users to a Users dataset. For more information see  Importing users individually.
    ///
    /// Parameters:
    ///   - datasetArn: The Amazon Resource Name (ARN) of the Users dataset you are adding the user or users to.
    ///   - users: A list of user data.
    ///   - logger: Logger use during operation
    @inlinable
    public func putUsers(
        datasetArn: String,
        users: [User],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = PutUsersRequest(
            datasetArn: datasetArn, 
            users: users
        )
        return try await self.putUsers(input, logger: logger)
    }
}

extension PersonalizeEvents {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: PersonalizeEvents, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
